package xinyu.customer.base;

import android.view.View;

import com.logos.common.base.BaseFragment;
import com.logos.common.widget.display.DisplayHelper;

import xinyu.customer.R;
import xinyu.customer.widget.dialog.CustomProgressDialog;

/**
 * @Description:
 * @Author: jianghe
 * @CreateDate: 2019/10/13 0013 17:11
 */
public class AppBaseFragment extends BaseFragment {

    private CustomProgressDialog mLoading;


    protected void measureTitleBarHeight(View view) {
        if (view != null) {
            view.setPadding(view.getLeft(), DisplayHelper.getStatusBarHeight(getContext()), view.getRight(), view.getBottom());
        }
    }

    /**
     * showLoading
     */
    public void showLoadingDialog() {
        if (getActivity().isFinishing()) {
            return;
        }
        if (null == mLoading) {
            mLoading = new CustomProgressDialog(getContext(), getString(R.string.loading_msg), true, true);
        }
    }

    /**
     * hideLoading
     */
    public void hideLoadingDialog() {
        if (getActivity() == null) {
            return;
        }
        if (getActivity().isFinishing()) {
            return;
        }
        if (mLoading != null && mLoading.isShowing()) {
            mLoading.dismiss();
            mLoading = null;
        }
    }

}
